﻿namespace MathVisualizer

open System.Drawing 

//Definisce l'espressione. Rappresentata come un albero.
type Expr0 =
| BigSum of Expr*Expr*Expr
| Integral of Expr*Expr*Expr
| Ratio of Expr*Expr
| Sum of Expr*Expr
| Sub of Expr*Expr
| Mul of Expr*Expr
| Exponent of Expr*Expr
| Subscript of Expr*Expr
| Literal of string
| Round of Expr
| Square of Expr
| Brace of Expr
| Group of Expr
| Equals of Expr*Expr
| Major of Expr*Expr
| Minor of Expr*Expr
| Geq of Expr*Expr
| Leq of Expr * Expr
| Approx of Expr*Expr
| Matrix of int*int*Expr[]
| Sqrt of Expr*Expr
| Concat of Expr*Expr
| Union of Expr*Expr*Expr
| Intersection of Expr*Expr*Expr
| Productor of Expr*Expr*Expr
| Limit of Expr*Expr 
| LeftArrow of Expr*Expr
| RightArrow of Expr*Expr
| Empty
and Expr(expr0:Expr0) = //Contenitore di un Expr0. Fornisce informazioni relative all'espressione associata.
        
    let mutable _rect  = new RectangleF() //vedi x.Box
    let mutable _container = new RectangleF() //vedi x.Container
    let mutable _expr = expr0 //vedi x.Expr
    let mutable _exprstring = "" //vedi x.ExprString
    let mutable _offset = new PointF() //vedi x.Offset
    let mutable _middleY = 0.f //vedi x.MiddleY
    let mutable _over = false //vedi x.MouseOver
    let mutable _clicked = false //vedi x.Clicked
    let mutable _graphicPath = new System.Drawing.Drawing2D.GraphicsPath()
    let mutable _iscontract = false

    //Espressione associata.
    member x.Expr 
        with get() = _expr
        and set e = _expr <- e

    //Rettangolo che definisce l'area di disegno del simbolo o della stringa (literal) dell'espressione.
    //Tali misure sono relative alla posizione del padre.
    member x.Box 
        with get() = _rect
        and set b1 = _rect <- b1
    
    //Rettangolo che definisce l'area di disegno dell'intera espressione x.Expr.
    ////Tali misure sono relative alla posizione del padre.
    member x.Container 
        with get() = _container
        and set c1 = 
            _container <- c1
        
    //Offset che
    member x.Offset 
        with get() = _offset
        and set o = _offset <- o
    
    
    member x.MiddleY 
        with get() = _middleY
        and set m = _middleY <- m
    
    
    member x.ExprString
        with get() = _exprstring
        and set e = _exprstring <- e 
    
    member x.IsContract
        with get() = _iscontract
        and set c = _iscontract <- c

    member x.MouseOver 
        with get() = _over
        and set s = _over <- s
    
    
    member x.Clicked 
        with get() = _clicked
        and set c = _clicked <- c

    member x.DrawRectagle = RectangleF(x.Offset.X + x.Box.X, x.Offset.Y + x.Box.Y, x.Box.Width, x.Box.Height)
    
    member x.DrawContainer = RectangleF(x.Offset.X, x.Offset.Y, x.Container.Width, x.Container.Height)
           
    member x.GraphicPath
        with get() = _graphicPath
        and set g = _graphicPath <- g

